package com.ygbhu.design.proxy.service.impl;

import com.ygbhu.design.proxy.service.Subject;

/**
 * @program: design-pattern
 * @description: 代理主题
 * @author: smzhu3
 * @create: 2021-07-27 14:40
 **/
public class ProxySubject implements Subject {

    private RealSubject realSubject;
    @Override
    public void getSubject() {
        if (realSubject == null) {
            realSubject = new RealSubject();
        }
        preRequest();
        realSubject.getSubject();
        postRequest();
    }
    public void preRequest() {
        System.out.println("访问真实主题之前的预处理。");
    }
    public void postRequest() {
        System.out.println("访问真实主题之后的后续处理。");
    }

}
